home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3c / getipnodebyname.z / getipnodebyname
Encoding:
Text File  |  2002-10-03  |  15.2 KB  |  265 lines

  1.  
  2.  
  3.  
  4. GGGGEEEETTTTIIIIPPPPNNNNOOOODDDDEEEEBBBBYYYYNNNNAAAAMMMMEEEE((((3333))))                                          GGGGEEEETTTTIIIIPPPPNNNNOOOODDDDEEEEBBBBYYYYNNNNAAAAMMMMEEEE((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyynnnnaaaammmmeeee,,,, ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyyaaaaddddddddrrrr,,,, ffffrrrreeeeeeeehhhhoooosssstttteeeennnntttt
  10.       - nodename-to-address and address-to-nodename translation
  11.  
  12. LLLLIIIIBBBBRRRRAAAARRRRYYYY
  13.      Standard C Library (libc, -lc)
  14.  
  15. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  16.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ttttyyyyppppeeeessss....hhhh>>>>
  17.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ssssoooocccckkkkeeeetttt....hhhh>>>>
  18.      ####iiiinnnncccclllluuuuddddeeee <<<<nnnneeeettttddddbbbb....hhhh>>>>
  19.  
  20.      ssssttttrrrruuuucccctttt hhhhoooosssstttteeeennnntttt ****ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyynnnnaaaammmmeeee((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****nnnnaaaammmmeeee,,,, iiiinnnntttt aaaaffff,,,,
  21.                               iiiinnnntttt ffffllllaaaaggggssss,,,, iiiinnnntttt ****eeeerrrrrrrroooorrrr____nnnnuuuummmm))));;;;
  22.      ssssttttrrrruuuucccctttt hhhhoooosssstttteeeennnntttt ****ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyyaaaaddddddddrrrr((((ccccoooonnnnsssstttt vvvvooooiiiidddd ****ssssrrrrcccc,,,, ssssoooocccckkkklllleeeennnn____tttt lllleeeennnn,,,,
  23.                               iiiinnnntttt aaaaffff,,,, iiiinnnntttt ****eeeerrrrrrrroooorrrr____nnnnuuuummmm))));;;;
  24.      vvvvooooiiiidddd ffffrrrreeeeeeeehhhhoooosssstttteeeennnntttt((((ssssttttrrrruuuucccctttt hhhhoooosssstttteeeennnntttt ****ppppttttrrrr))));;;;
  25.  
  26. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  27.      ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyynnnnaaaammmmeeee and ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyyaaaaddddddddrrrr functions are very similar to
  28.      ggggeeeetttthhhhoooossssttttbbbbyyyynnnnaaaammmmeeee((((3333NNNN)))) and ggggeeeetttthhhhoooossssttttbbbbyyyyaaaaddddddddrrrr((((3333NNNN)))).... The functions cover all the
  29.      functionalities provided by the older ones, and provide better interface
  30.      to programmers.  The functions require additional arguments, _a_f, and
  31.      _f_l_a_g_s, for specifying address family and operation mode.  The additional
  32.      arguments allow programmer to get address for a nodename, for specific
  33.      address family (such as AF_INET or AF_INET6).  The functions also require
  34.      an additional pointer argument, _e_r_r_o_r__n_u_m to return the appropriate error
  35.      code, to support thread safe error code returns.
  36.  
  37.      The type and usage of the return value, struct hostent is described in
  38.      _g_e_t_h_o_s_t_b_y_n_a_m_e(_3_N).
  39.  
  40.      For ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyynnnnaaaammmmeeee,,,, the _n_a_m_e argument can be either a node name or a
  41.      numeric address string (i.e., a dotted-decimal IPv4 address or an IPv6
  42.      hex address).  The _a_f argument specifies the address family, either
  43.      AF_INET or AF_INET6. The _f_l_a_g_s argument specifies the types of addresses
  44.      that are searched for, and the types of addresses that are returned.  We
  45.      note that a special flags value of AI_DEFAULT (defined below) should
  46.      handle most applications.  That is, porting simple applications to use
  47.      IPv6 replaces the call
  48.  
  49.         hptr = gethostbyname(name);
  50.  
  51.      with
  52.  
  53.         hptr = getipnodebyname(name, AF_INET6, AI_DEFAULT, &error_num);
  54.  
  55.      Applications desiring finer control over the types of addresses searched
  56.      for and returned, can specify other combinations of the _f_l_a_g_s argument.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. GGGGEEEETTTTIIIIPPPPNNNNOOOODDDDEEEEBBBBYYYYNNNNAAAAMMMMEEEE((((3333))))                                          GGGGEEEETTTTIIIIPPPPNNNNOOOODDDDEEEEBBBBYYYYNNNNAAAAMMMMEEEE((((3333))))
  71.  
  72.  
  73.  
  74.      A _f_l_a_g_s of 0 implies a strict interpretation of the _a_f argument:
  75.  
  76.      *    If _f_l_a_g_s is 0 and _a_f is AF_INET, then the caller wants only IPv4
  77.           addresses.  A query is made for A records.  If successful, the IPv4
  78.           addresses are returned and the h_length member of the hostent
  79.           structure will be 4, else the function returns a NULL pointer.
  80.  
  81.      *    If _f_l_a_g_s is 0 and if _a_f is AF_INET6, then the caller wants only IPv6
  82.           addresses.  A query is made for AAAA records.  If successful, the
  83.           IPv6 addresses are returned and the h_length member of the hostent
  84.           structure will be 16, else the function returns a NULL pointer.
  85.  
  86.      Other constants can be logically-ORed into the _f_l_a_g_s argument, to modify
  87.      the behavior of the function.
  88.  
  89.      *    If the AI_V4MAPPED flag is specified along with an _a_f of AF_INET6,
  90.           then the caller will accept IPv4-mapped IPv6 addresses.  That is, if
  91.           no AAAA records are found then a query is made for A records and any
  92.           found are returned as IPv4-mapped IPv6 addresses h_length will be
  93.           16).  The AI_V4MAPPED flag is ignored unless _a_f equals AF_INET6.
  94.  
  95.      *    The AI_V4MAPPED_CFG flag is exactly same as the AI_V4MAPPED flag
  96.           only if the kernel supports IPv4-mapped IPv6 address.
  97.  
  98.      *    If the AI_ALL flag is used in conjunction with the AI_V4MAPPED flag,
  99.           and only used with the IPv6 address family.  When AI_ALL is
  100.           logically or'd with AI_V4MAPPED flag then the caller wants all
  101.           addresses: IPv6 and IPv4-mapped IPv6.  A query is first made for
  102.           AAAA records and if successful, the IPv6 addresses are returned.
  103.           Another query is then made for A records and any found are returned
  104.           as IPv4-mapped IPv6 addresses.  h_length will be 16.  Only if both
  105.           queries fail does the function return a NULL pointer.  This flag is
  106.           ignored unless af equals AF_INET6.  If both AI_ALL and AI_V4MAPPED
  107.           are specified, AI_ALL takes precedence.
  108.  
  109.      *    The AI_ADDRCONFIG flag specifies that a query for AAAA records
  110.           should occur only if the node has at least one IPv6 source address
  111.           configured and a query for A records should occur only if the node
  112.           has at least one IPv4 source address configured.  For example, if
  113.           the node has no IPv6 source addresses configured, and _a_f equals
  114.           AF_INET6, and the node name being looked up has both AAAA and A
  115.           records, then:  (a) if only AI_ADDRCONFIG is specified, the function
  116.           returns a NULL pointer; (b) if AI_ADDRCONFIG | AI_V4MAPPED is
  117.           specified, the A records are returned as IPv4-mapped IPv6 addresses;
  118.  
  119.      The special flags value of AI_DEFAULT is defined as
  120.  
  121.         #define  AI_DEFAULT  (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
  122.  
  123.      We noted that the ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyynnnnaaaammmmeeee function must allow the _n_a_m_e argument
  124.      to be either a node name or a literal address string (i.e., a dotted-
  125.      decimal IPv4 address or an IPv6 hex address).  This saves applications
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. GGGGEEEETTTTIIIIPPPPNNNNOOOODDDDEEEEBBBBYYYYNNNNAAAAMMMMEEEE((((3333))))                                          GGGGEEEETTTTIIIIPPPPNNNNOOOODDDDEEEEBBBBYYYYNNNNAAAAMMMMEEEE((((3333))))
  137.  
  138.  
  139.  
  140.      from having to call iiiinnnneeeetttt____ppppttttoooonnnn((((3333)))) to handle literal address strings.  When
  141.      the _n_a_m_e argument is a literal address string, the _f_l_a_g_s argument is
  142.      always ignored.
  143.  
  144.      There are four scenarios based on the type of literal address string and
  145.      the value of the _a_f argument.  The two simple cases are when _n_a_m_e is a
  146.      dotted-decimal IPv4 address and _a_f equals AF_INET , or when _n_a_m_e is an
  147.      IPv6 hex address and _a_f equals AF_INET6.  The members of the returned
  148.      hostent structure are:  _h__n_a_m_e points to a copy of the _n_a_m_e argument,
  149.      _h__a_l_i_a_s_e_s is a NULL pointer, _h__a_d_d_r_t_y_p_e is a copy of the _a_f argument,
  150.      _h__l_e_n_g_t_h is either 4 (for AF_INET) or 16 (for AF_INET6), _h__a_d_d_r__l_i_s_t[_0]
  151.      is a pointer to the 4-byte or 16-byte binary address, and _h__a_d_d_r__l_i_s_t[_1]
  152.      is a NULL pointer.
  153.  
  154.      When _n_a_m_e is a dotted-decimal IPv4 address and _a_f equals AF_INET6, and
  155.      AI_V4MAPPED is specified, an IPv4-mapped IPv6 address is returned:
  156.      _h__n_a_m_e points to an IPv6 hex address containing the IPv4-mapped IPv6
  157.      address, _h__a_l_i_a_s_e_s is a NULL pointer, _h__a_d_d_r_t_y_p_e is AF_INET6, _h__l_e_n_g_t_h is
  158.      16, _h__a_d_d_r__l_i_s_t[_0] is a pointer to the 16-byte binary address, and
  159.      _h__a_d_d_r__l_i_s_t[_1] is a NULL pointer.
  160.  
  161.      It is an error when _n_a_m_e is an IPv6 hex address and _a_f equals AF_INET.
  162.      The function's return value is a NULL pointer and the value pointed to by
  163.      _e_r_r_o_r__n_u_m equals HOST_NOT_FOUND.
  164.  
  165.      ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyyaaaaddddddddrrrr takes almost the same argument as ggggeeeetttthhhhoooossssttttbbbbyyyyaaaaddddddddrrrr((((3333)))),,,, but
  166.      adds a pointer to return an error number.  Additionally it takes care of
  167.      IPv4-mapped IPv6 addresses, and IPv4-compatible IPv6 addresses.
  168.  
  169.      ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyynnnnaaaammmmeeee and ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyyaaaaddddddddrrrr dynamically allocate the structure to
  170.      be returned to the caller.  ffffrrrreeeeeeeehhhhoooosssstttteeeennnntttt reclaims memory region allocated
  171.      and returned by ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyynnnnaaaammmmeeee or ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyyaaaaddddddddrrrr
  172.  
  173. FFFFIIIILLLLEEEESSSS
  174.      ////eeeettttcccc////hhhhoooossssttttssss
  175.      ////eeeettttcccc////iiiippppnnnnooooddddeeeessss
  176.      ////eeeettttcccc////nnnnsssssssswwwwiiiittttcccchhhh....ccccoooonnnnffff
  177.      ////eeeettttcccc////rrrreeeessssoooollllvvvv....ccccoooonnnnffff
  178.  
  179. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  180.      ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyynnnnaaaammmmeeee and ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyyaaaaddddddddrrrr returns NULL on errors.  The integer
  181.      values pointed to by _e_r_r_o_r__n_u_m may then be checked to see whether this is
  182.      a temporary failure or an invalid or unknown host.  The meanings of each
  183.      error code are described in ggggeeeetttthhhhoooossssttttbbbbyyyynnnnaaaammmmeeee((((3333))))....
  184.  
  185. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  186.      ggggeeeettttaaaaddddddddrrrriiiinnnnffffoooo((((3333)))),,,, ggggeeeettttnnnnaaaammmmeeeeiiiinnnnffffoooo((((3333)))),,,, ggggeeeetttthhhhoooossssttttbbbbyyyyaaaaddddddddrrrr((((3333)))),,,, ggggeeeetttthhhhoooossssttttbbbbyyyynnnnaaaammmmeeee((((3333)))),,,,
  187.      hhhhoooossssttttssss((((5555)))),,,, nnnnsssssssswwwwiiiittttcccchhhh....ccccoooonnnnffff((((5555)))),,,, sssseeeerrrrvvvviiiicccceeeessss((((5555)))),,,, hhhhoooossssttttnnnnaaaammmmeeee((((7777)))),,,, nnnnaaaammmmeeeedddd((((8888))))....
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. GGGGEEEETTTTIIIIPPPPNNNNOOOODDDDEEEEBBBBYYYYNNNNAAAAMMMMEEEE((((3333))))                                          GGGGEEEETTTTIIIIPPPPNNNNOOOODDDDEEEEBBBBYYYYNNNNAAAAMMMMEEEE((((3333))))
  203.  
  204.  
  205.  
  206. STANDARDS
  207.      ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyynnnnaaaammmmeeee and ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyyaaaaddddddddrrrr are documented in "Basic Socket
  208.      Interface Extensions for IPv6" (RFC2553).
  209.  
  210. BBBBUUUUGGGGSSSS
  211.      ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyynnnnaaaammmmeeee and ggggeeeettttiiiippppnnnnooooddddeeeebbbbyyyyaaaaddddddddrrrr do not handle scoped IPv6 address
  212.      properly.  If you use these functions, your program will not be able to
  213.      handle scoped IPv6 addresses.  For IPv6 address manipulation,
  214.      ggggeeeettttaaaaddddddddrrrriiiinnnnffffoooo((((3333)))) and ggggeeeettttnnnnaaaammmmeeeeiiiinnnnffffoooo((((3333)))) are recommended.
  215.  
  216.      The current implementation is not thread-safe.
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.